<?php
class  PanelView{
	const _location = "section/admin/pages/";
	
	public static function schow_main_pages_list($__pages){
		tools::_display(PanelView::_location."const_pages_tree_header.tpl");	
		PanelView::get_category_list(0,0,$__pages);
		tools::_display(PanelView::_location."const_pages_tree_fotter.tpl");	
	}
	
	public static function CMSSettingsForm(){
		tools::_display(PanelView::_location."const_pages_settings.tpl");
	}
	
	/**
	 * generuje tree z stron wprowadzonych przez uzytkownika do cmsa
	 * 
	 * @param $id_kategoria_parent
	 * @param $id_kategoria_back
	 * @param $category
	 * @param $setup
	 * @return unknown_type
	 */
	public static function get_category_list($id_kategoria_parent,$id_kategoria_back,$category,$setup=false){
		$i = 0;
		$sub = 'open';
		$czy_jest_nastepny_poziom = false;
		if ($sub){
				foreach ($category as $key1 => $rows) {
					if ( $rows['id_p_page'] == $id_kategoria_parent ){	
						$czy_jest_nastepny_poziom = true;
						if ($sub == 'open'){ 
							echo "<ul id=\"cat{$rows['id_page']}\" class=\"stan".PanelView::check_open_close_tree($rows['id_p_page'])."\">";
							$sub = 'close';				
						}
						tools::_assign('categ',$rows);

						echo "<li> ";
						tools::_display("section/admin/pages/const_pages_tree.tpl");
						PanelView::get_category_list($rows['id_page'],$rows['id_p_page'],$category);
						
						echo '</li>';
						$i++;
					}
				}			
			if ($sub == 'close') echo '</ul>';
		}
	}
	public static function check_open_close_tree($id_kategoria){
		global $objSession;
		$idpage__ = $idpage__['mtree'][$id_kategoria];
		return 	$objSession->$idpage__;
		//return (isset($_SESSION['mtree'][$id_kategoria]) ) ? $_SESSION['mtree'][$id_kategoria] : 0 ;
	}	
	public static function edit_one_page($__page,$__sections){
		tools::_assign("page",$__page);
		tools::_assign("sections",$__sections);
		tools::_display(PanelView::_location."const_page_edit.tpl");
	}
	
	public static function add_new_page($__id_p_page=null){
		global $config;
		if($__id_p_page != 0) $pageData_  = PanelModel::get_page_data($__id_p_page);
		tools::_assign("id_p_page",$__id_p_page);
		tools::_assign("id_p_grup",$pageData_['id_grup']);
		tools::_assign("newpage",array("id_lang"=>$config->__lang));
		tools::_display(PanelView::_location."const_page_new.tpl");
	}
	
	public static function edit_one_section($__section,$__extenction_name = null,$view=""){
		global $smarty;
		//$__extenction_name = ( is_null($__extenction_name) ) ? $__section['id_exten'] : null;
		if (!empty($__extenction_name)) $smarty->assign("extenction_info__",array("exten"=>$__extenction_name,"exten_install"=>$__extenction_name."/install.tpl"));
		
		$smarty->assign('section',$__section);
		$smarty->display(PanelView::_location."const_page_section_edit{$view}.tpl");
	}
	
	public static function new_section_form($__section){
		tools::_assign('section',$__section);
		tools::_display(PanelView::_location."const_page_section_new.tpl");
	}
	
}
?>